<?php
/**
 * Copyright (c) Enalean, 2012. All Rights Reserved.
 *
 * This file is a part of Tuleap.
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * A pane to be displayed in AgileDashboard
 */
class Tracker_Artifact_Burndown_Pane extends AgileDashboard_Pane {

    /**
     * @var Tracker_Artifact_Burndown_PaneInfo 
     */
    private $info;

    /**
     * @var Tracker_Artifact
     */
    private $artifact;
    
    /**
     * @var Tracker_FormElement_Field_Burndown
     */
    private $field;
    
    /**
     * @var PFUser
     */
    private $user;

    public function __construct(
            Tracker_Artifact_Burndown_PaneInfo $info,
            Tracker_Artifact $artifact,
            Tracker_FormElement_Field_Burndown $field,
            PFUser $user) {
        $this->info              = $info;
        $this->artifact          = $artifact;
        $this->field             = $field;
        $this->user              = $user;
    }

    public function getIdentifier() {
        return $this->info->getIdentifier();
    }

    public function getUriForMilestone(Planning_Milestone $milestone) {
        return $this->info->getUriForMilestone($milestone);
    }
    
    /**
     * @see AgileDashboard_Pane::getFullContent()
     */
    public function getFullContent() {
        return $this->getPaneContent();
    }

    /**
     * @see AgileDashboard_Pane::getMinimalContent()
     */
    public function getMinimalContent() {
        return '';
    }

    private function getPaneContent() {
        return $this->field->fetchBurndownReadOnly($this->artifact);
    }
}